<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
 <form οnsubmit="return false;">
  <h3></h3>
  <textarea id="responseText" style="width: 500px; height: 100px;"></textarea>
  <br>
   </form>
  方法1: 通过websocket 管理通道 下达指令<br>
  to:  <input type ="text" id="cliid" value="2"/ ><br>
  订阅:  <input type ="text" id="sub" value="topic1"/ ><br>
  msg:  <input type="text" id="msg"  name="message" style="width: 300px" value="消息">
  <br> <br>
    <input type ="button" onclick="f查客户集()" value="查客户集"/>
    <input type ="button" onclick="f查终端集()" value="查终端集"/><br><br>
 <input type ="button" onclick="f订阅主题()" value="订阅主题"/>
 <input type ="button" onclick="f退订主题()" value="退订主题"/>
  <input type ="button" onclick="f查订阅()" value="查订阅"/><br><br>
 <input type ="button" onclick="f推送个人(2)" value="推送个人2"/>
  <input type ="button" onclick="f推送主题(2)"  value="推送主题2"/>
 <input type ="button" onclick="f广播(2)"  value="广播2"/><br><br>
 <input type ="button" onclick="f推送个人(3)" value="推送个人3"/>
  <input type ="button" onclick="f推送主题(3)" value="推送主题3"/>
 <input type ="button" onclick="f广播(3)" value="广播3"/><br>
 <br>

 <br>
 <select id ="cmd">
 <option value="推送个人2"> 推送个人2</option>
 <option value="推送主题2"> 推送主题2</option>
 <option value="广播2"> 广播2</option>
 <option value="推送个人3"> 推送个人3</option>
 <option value="推送主题3"> 推送主题3</option>
 <option value="广播3"> 广播3</option>
 </select>
   to:  <input type ="text" id="to" value="topic1"/ ><br>
  msg:  <input type="text" id="content"  name="message" style="width: 300px" value="消息"><br>
  
<br>
 <input type ="button" onclick="fcall2()" value="方法2: 通过wsadmin.jsp 下达消息指令"/>
  <input type ="button" onclick="fcall3()" value="方法3: 通过rocketmq 下达消息指令"/>
 <br>
</body>
</html>
<script src="../js/hyl.ws.js"></script>
<script type="text/javascript">
  var arr=[]
  var hws = new HylWSocket("ws://localhost:8080/hjsp/wsadmin", function(e) {
    //console.log(e.data)
    arr.push(e.data)
    document.getElementById("responseText").innerHTML+=e.data;
  })
  
  function fcall2(){
	    var cmd=document.getElementById("cmd").value;    
	    var to=document.getElementById("to").value;
	    var content=document.getElementById("content").value;
	    var url="wsadmin.jsp?cmd="+cmd+"&to="+to+"&text="+content;
	    window.open(url,'newwindow')	
}
  function fcall3(){
	    var cmd=document.getElementById("cmd").value;    
	    var to=document.getElementById("to").value;
	    var content=document.getElementById("content").value;
	    var url="wsmq.jsp?cmd="+cmd+"&to="+to+"&text="+content;
	    window.open(url,'newwindow')	
}
  function f订阅主题(){
	  var id =document.getElementById("cliid").value;
	  var title =document.getElementById("sub").value;
	  hws.send("{cmd:'订阅主题',to:'"+id+"',text:'"+title+"'}")
  }
  function f退订主题(){
	  var id =document.getElementById("cliid").value;
	  var title =document.getElementById("sub").value;
	  hws.send("{cmd:'退订主题',to:'"+id+"',text:'"+title+"'}")
  }
  function f查订阅(){
	  hws.send("{cmd:'查订阅'}")
  }
  function f查客户集(){
	  hws.send("{cmd:'查客户集'}")
  }
  function f查终端集(){
	  hws.send("{cmd:'查终端集'}")
  }


  function f推送个人(cmd){
	  var id =document.getElementById("cliid").value;
	  var msg =document.getElementById("msg").value;
	  hws.send("{cmd:'推送个人"+cmd+"',to:'"+id+"',text:'"+msg+"'}")
  }
  function f推送主题(cmd){
	  var id =document.getElementById("sub").value;
	  var msg =document.getElementById("msg").value;
	  hws.send("{cmd:'推送主题"+cmd+"',to:'"+id+"',text:'"+msg+"'}")
  }
  function f广播(cmd){
	  var msg =document.getElementById("msg").value;
	  hws.send("{cmd:'广播"+cmd+"',text:'"+msg+"'}")
  }
</script>